<%@ page contentType="text/html;charset=UTF-8" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="shiro" uri="http://shiro.apache.org/tags" %>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %> 
<%@ taglib prefix="tags" tagdir="/WEB-INF/tags" %>
<c:set var="ctx" value="${pageContext.request.contextPath}"/>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
	<title>_入库登记</title>
	<script type="text/javascript">
		var filterParam = {};
		var datatable_content;
		function initTable(status){
			if(status=="status"){
				//alert(1);
				jQuery("#_orderbystatus").val("status") ;
			}else{
				jQuery("#_orderbystatus").val("id") ;
			}
			datatable_content = $("#contentTable").dataTable({
			   "bServerSide":true,
			   "bAutoWidth":false,
	           "sAjaxSource":'${ctx}/instorageBill/queryInstorageBill',
	           "fnServerData": callback,
	           "fnRowCallback":rowCallBack,
	           "sScrollX":"120%",
	           "bFilter": false,
	           "bSort": false,
	           "sZeroRecords": "查询无记录！",
	           "bProcessing": true,
	           "oLanguage": {
	               "sUrl": '${ctx}/static/v2/js/plugins/datatables/cn.txt'
	            },
	             "aoColumns":[
	             	{"mData": null},
	             	 {"mData": "customer.customerName"},
	             	 {"mData": null},
	             	 {"mData": null},
	             	 {"mData": null},
	             	 {"mData": null},
	             	 {"mData": null},
	             	 {"mData": null},
	             	 {"mData": null},
	             	 {"mData": null},
	             	 {"mData": null},
	             	 {"mData": "boxNum"},
	             	 {"mData": "skuNum"},
	             	 {"mData": "goodsNum"},
	             	 {"mData": null},
	             	 {"mData": null},
	             	 {"mData": null},
	             	 {"mData": null},
	             	 {"mData": null},
	             ],
	             "aoColumnDefs":[
	             	{"aTargets": [2],
		              "mRender": function (data, display, row) {
							return  row.billType == "customer" ? "<font color=red>采购入库</font>" : 
									row.billType == "allot" ? "<font color=green>调拨入库</font>" :
									row.billType == "cancelOrder" ? "<font color=blue>取消单入库</font>" :
									row.billType == "returnOrder" ? "<font color=black>退回件入库</font>" :
									row.billType == "preOrder" ? "<font color=black>预约入库</font>" : "";
			           }
		            },
	             	{"aTargets": [3],
		              "mRender": function (data, display, row) {
							return  row.errorFlag == "error" ? "<font color=red>报损件</font>" : "完好件";
			           }
		            },
	             	{"aTargets": [4],
		              "mRender": function (data, display, row) {
							return  row.inwarehouse ? row.inwarehouse.groupName : "";
			           }
		            },
	             	{"aTargets": [5],
		              "mRender": function (data, display, row) {
							return  row.outwarehouse ? row.outwarehouse.groupName : "";
			           }
		            },
	             	{"aTargets": [6],
		              "mRender": function (data, display, row) {
							return  "<a href=\"${ctx}/instorageBill/v2_toInstorageBillDetailPage/"+row.billCode+"\" title=\"【入库信息详情】\">"+row.billCode+"</a>";
			           }
		            },
	             	{"aTargets": [7],
		              "mRender": function (data, display, row) {
							return  row.billType == "customer" ? row.aboutCode : 
									row.billType == "allot" ? "<a href=\"${ctx}/outstorageBill/v2_toOutstorageBillDetailPage/"+row.aboutCode+"\" title=\"【调拨出库信息】\">"+row.aboutCode+"</a>" :
									row.billType == "cancelOrder" ? row.aboutCode :
									(row.billType == "returnOrder" && row.preBill) ? "<a href=\"${ctx}/v2/preInstorageBill/queryPreInstorageInfo/"+row.preBill.id+"\" title=\"【入库预约信息】\">"+row.aboutCode+"</a>" :
									(row.billType == "preOrder" && row.preBill)? "<a href=\"${ctx}/v2/preInstorageBill/queryPreInstorageInfo/"+row.preBill.id+"\" title=\"【入库预约信息】\">"+row.aboutCode+"</a>" : row.aboutCode;
			           }
		            },
	             	{"aTargets": [8],
		              "mRender": function (data, display, row) {
							return  row.preBill ? row.preBill.customerOrderNo : "";
			           }
		            },
	             	{"aTargets": [9],
		              "mRender": function (data, display, row) {
							return  row.preBill ? (row.preBill.oldCusOrderNo ? row.preBill.oldCusOrderNo : row.preBill.sourceOrdNo) : "";
			           }
		            },
	             	{"aTargets": [10],
		              "mRender": function (data, display, row) {
							return  row.preBill ? row.preBill.expressNo : "";
			           }
		            },
	             	{"aTargets": [14],
		              "mRender": function (data, display, row) {
							return new Date(row.createTime.time).Format("yyyy-MM-dd hh:mm:ss");
			           }
		            },
	             	{"aTargets": [15],
		              "mRender": function (data, display, row) {
							return  row.status == "0" ? "待登记" :
									row.status == "1" ? "入库登记" :
									row.status == "2" ? "领取点收任务" :
									row.status == "3" ? "点收完成" :
									row.status == "4" ? "领取上架任务" :
									row.status == "5" ? "上架完成" : 
									row.status == "6" ? "已取消" : "";
			           }
		            },
	             	{"aTargets": [16],
		              "mRender": function (data, display, row) {
		              		var text = (row.billType == "preOrder" || row.billType == "allot") && (row.status == "3"||row.status == "4"||row.status == "5") ? (row.matchFlag == "0" ? "<font color=red>异常</font>" : row.matchFlag == "1" ? "正常" : "") : "";
		              		return text ? "<a href=\"${ctx}/instorageBill/v2_queryInstorageCountCompareInfo?billCode="+row.billCode+"\" title=\"【查看详情】\">"+text+"</a>" : "";
			           }
		            },
	             	{"aTargets": [17],
		              "mRender": function (data, display, row) {
							return  row.creater ? row.creater.realname : "";
			           }
		            },
	             	{"aTargets": [18],
		              "mRender": function (data, display, row) {
		              	var rs = "";
			                // 设置取消按钮
		              		if (row.cancelFlag == 1 && (row.status == '0' || row.status == '1')) {
		              		    rs += "<button type='button' class='btn btn-warning' onclick='cancelBill("+row.id+")'>取消</button>";
		              		}
		              		if (row.status == '1'){
		              			if(row.billType == "preOrder"){
		              				//ERP传进来的入库单预约入库情况下取消删除按钮
		              			}else{
		              				rs += "<button type=\"button\" class=\"btn btn-danger\" onclick=\"deleteBill('"+row.id+"')\">删除</button>";
		              			}
							}
						    if (row.status == '0'){
						    	if(row.billType == "returnOrder"){
						    		if(row.preBill && row.preBill.returngoodStatus==1){
						    		//	rs += "<button type=\"button\"  class=\"btn btn-primary\" onclick=\"\" id=\"confirmIn_btn_"+row.id+"\">确认登记</button>";
						    			if(row.customer.customerCode=="MID"){
							    			rs += "<a href=\"#assignSubWarehouseDiv\" onclick=\"assignWarehouse('"+row.id+"')\" role=\"button\" id=\"confirmIn_btn_"+row.id+"\" class=\"btn btn-primary\" data-toggle=\"modal\">选择仓库</a>";
						    			}else {
						    				rs += "<button type=\"button\"  class=\"btn btn-primary\" onclick=\"confirmIn('"+row.id+"')\" id=\"confirmIn_btn_"+row.id+"\">确认登记</button>";
						    			}
						    		}
						    	}else{
// 						    		rs += "<button type=\"button\"  class=\"btn btn-primary\" onclick=\"confirmIn('"+row.id+"')\" id=\"confirmIn_btn_"+row.id+"\">确认登记</button>";
						    		if(row.customer.customerCode=="MID"){
						    			rs += "<a href=\"#assignSubWarehouseDiv\" onclick=\"assignWarehouse('"+row.id+"')\" role=\"button\" id=\"confirmIn_btn_"+row.id+"\" class=\"btn btn-primary\" data-toggle=\"modal\">选择仓库</a>";
					    			}else {
					    				rs += "<button type=\"button\"  class=\"btn btn-primary\" onclick=\"confirmIn('"+row.id+"')\" id=\"confirmIn_btn_"+row.id+"\">确认登记</button>";
					    			}
						    		
						    	}
						    }else if(row.status == '6'){
						       rs += "<button type=\"button\" class=\"btn btn-default\">已取消</button>";
						    }else {
					           rs += "<button type=\"button\" class=\"btn btn-default\">已登记</button>";
						    }
						    
							if(row.preBill && row.billType =='preOrder' && row.syncMdFlag == '1' && row.matchFlag == '0' && row.updateFlag == '0'){
								 rs += "<a class=\"btn btn-sm btn-primary\" onclick=\"createInBillAgain('"+row.id+"')\">继续收货</a>";
							}
							if(row.status=='5'&&row.customer.openQm=="1"){
								rs += "<button type=\"button\"class=\"btn btn-primary\" onclick=\"sendqm('"+row.id+"')\" id=\"sendqm_btn_"+row.id+"\">重发奇门接口</button>";
							}
							return  rs;
			           }
		            },
	             ]
			});
		}
		function filter(item){
			filterParam[item.name] = item;
		}
		function callback(sSource, aoData, fnCallback ) {
		   	var formParam = $("#queryForm").serializeArray();
			for(var n in filterParam){
				formParam.push(filterParam[n]);
			}
		   $.ajax({ 
		       "type": "post",
		       "contentType": "application/json", 
		       "url": sSource,    
		       "dataType": "json",   
		       "data": JSON.stringify(aoData.concat(formParam)),
		       "success": fnCallback  
		   });
		}
		
		/**
		*创建了行的回调
		*nRow为当前的tr
		*/
		function rowCallBack(nRow, aData, iDisplayIndex, iDisplayIndexFull){
			var iDisplayStart = datatable_content.fnSettings()._iDisplayStart;
			$("td:eq(0)", nRow).html(iDisplayStart+iDisplayIndex+1);
		}
		
		function load(status){
			if($("#queryForm").valid()){
				if (datatable_content) {
					datatable_content.fnDestroy();
				}
				initTable(status);
			}
		}
        $(function() {
		    $("#queryForm").validate(); 
		    $("#inputForm").validate();
			$("#_fromDate").datepicker({ format : 'yyyy-mm-dd'});
			$("#_toDate").datepicker({ format : 'yyyy-mm-dd' });
			
			var now = new Date();
			var tomorrow = new Date();
			tomorrow.setDate(now.getDate()+1);
			$("#_fromDate").val(now.Format("yyyy-MM-dd"));
			$("#_toDate").val(tomorrow.Format("yyyy-MM-dd"));
       });
	  
        //重设表单
        function formReset(){
          $("input[type=reset]").trigger("click");
        }
        
       //删除入库单
       function deleteBill(billId){
          
          $.ajax({
			   type : 'post',
				url : '${ctx}/instorageBill/ajaxDelete',
				data : {
					billId:billId
				},
				dataType : 'json',
				success : function(data) {
				   if(data==true){
				      location.href="${ctx}/instorageBill/v2_toInstorageBillListPage";
				   }else{
				      jAlert("网络繁忙，请稍后重试...","温馨提示");
				   }	
				},
				error : function() {
					jAlert("网络繁忙，请稍后重试...","温馨提示");
				}
			}); 
          
       }
       
       // 取消入库单
       function cancelBill(billId){
          
          $.ajax({
			   type : 'post',
				url : '${ctx}/instorageBill/ajaxCancel',
				data : {
					billId:billId
				},
				dataType : 'json',
				success : function(data) {
				    if(data.status==1){
				        alert(data.content);
				        location.href="${ctx}/instorageBill/v2_toInstorageBillListPage";
				    }else if (data.status==0) {
				        alert(data.content);
				    }	
				},
				error : function() {
					allert("网络繁忙，请稍后重试...","温馨提示");
				}
			}); 
          
       }

		//添加入库单	
 		function add(){
 		  $("#windowTitle").html("添加入库单");
 		  $("input[type=reset]").trigger("click");
 		  $("#submit_btn").attr("disabled",null);
		  $("#customerCode").attr("disabled",false);
		  $("#inwarehouseCode").attr("disabled",false);
 		  $("#inputForm").attr("action",'${ctx}/instorageBill/create');
 		}
 		
 		//修改入库单
 		function update(billId){
 		
 		   $("input[type=reset]").trigger("click");
 		   $("#inputForm").attr("action",'${ctx}/instorageBill/update');
 		
 		   $.ajax({
			   type : 'post',
				url : '${ctx}/instorageBill/ajaxGetBill',
				data : {
					billId:billId
				},
				dataType : 'json',
				success : function(data) {
				
				    $("#customerCode").val(data.customerCode);
					$("#inwarehouseCode").val(data.inwarehouseCode);
					$("#remarks").val(data.remarks);
					$("#id").val(data.id);
					$("#aboutCode").val(data.aboutCode);
		             
					$("#customerCode").attr("disabled",true);
					$("#inwarehouseCode").attr("disabled",true);
					$("#windowTitle").html("入库单号："+data.billCode);
				},
				error : function() {
					jAlert("网络繁忙，请稍后重试...","温馨提示");
				}
			 }); 
				
 		}
 		//继续收货
 		function createInBillAgain(id){
	 		jConfirm("请按照仓库实际到货情况处理,确认要继续收货吗?","温馨提示",function(r){
	 			if(r){
			 		$.ajax({
					   type : 'post',
						url : '${ctx}/instorageBill/v2_createInBillAgain',
						data : {
							id:id
						},
						dataType : 'json',
						success : function(data) {
							jAlert("成功创建入库单.");
							load();
						},
						error : function() {
							jAlert("网络繁忙，请稍后重试...","温馨提示");
						}
					 }); 
				 }
	 		});
 		}
 		//添加or修改
 		function mySubmit(){
 		   $("#submit_btn").attr("disabled",true);
 		   if($("#customerCode").val() != 'ZJDS'){
	 		  var openQm = $("#customerCode").find("option:selected").attr("openqm");
	 		  if(openQm == "1"){
	 			jAlert("奇门商家不允许手工登记入库！");
	 			$("#submit_btn").attr("disabled",false);  
	 			return;
	 		  }
 		   }
 		   if( $("#inputForm").valid() ){
 		      
 		        var customerCode=$("#customerCode").val().trim();
 		        var inwarehouseCode=$("#inwarehouseCode").val().trim();
 		        var aboutCode=$("#aboutCode").val().trim();
 		        var errorFlag=$("#errorFlag").val().trim();
 		        var remarks=$("#remarks").val().trim();
 		        var billType=$("#billType").val().trim();
 		        var id=$("#id").val().trim();
 		        
 		        if($("#customerCode").val() == 'MID'){
			  		jAlert("美的不允许登记入库单.","温馨提示");
			  		return;
			  	}
 		        
 		        //检验： 如果是 【取消单】 或者 【退回件】入库，必须填写相关单号：能容订单号。
 		        if( billType=='cancelOrder' || billType=='returnOrder'  ){
 		            if(aboutCode=='' || aboutCode.indexOf('PD')!=0 || aboutCode.length<16){
 		                jAlert("【取消单】 或者 【退回件】，相关单号必须填写 ：正确的能容订单号","温馨提示");
 		                $("#submit_btn").attr("disabled",false);  
 		                return ;
 		            }
 		        }
 		        
 		       
 		        $.ajax({
				   type : 'post',
					url : '${ctx}/instorageBill/ajaxCreateOrUpdate',
					data : {
						customerCode:customerCode,
						inwarehouseCode:inwarehouseCode,
						aboutCode:aboutCode,
						errorFlag:errorFlag,
						remarks:remarks,
						billType:billType,
						id:id
					},
					dataType : 'json',
					success : function(data) {
					   if(data==true){
					     location.href="${ctx}/instorageBill/v2_toInstorageBillListPage";
					   }else{
					     jAlert("网络繁忙，请稍后重试...","温馨提示");
					   }
					   $("#submit_btn").attr("disabled",false);
					},
					error : function() {
						jAlert("网络繁忙，请稍后重试...","温馨提示");
						$("#submit_btn").attr("disabled",false);
					}
				 }); 
 		      
 		   }else{
 		      $("#submit_btn").attr("disabled",false);
 		   }
 		}
 		var selectBillId = "";
		function assignWarehouse(billId) {
			selectBillId = billId;
			
		    $.ajax({
				   type : 'post',
					url : '${ctx}/instorageBill/querySubWarehouse',
					data : {
						billId:billId
					},
					dataType : 'json',
					success : function(data) {
					   if(data.status=="success"){
							var warehouseList = data.warehouseList;
							var tbody = $("#selectAssignWarehouseBody");
							var tbodyStr = "";
							tbody.html(tbodyStr);
							for(var i = 0 ;i < warehouseList.length ; i++) {
								var warehouseObj = warehouseList[i];
								tbodyStr += "<tr>";
								tbodyStr += "<td><input type='radio' name='warehouseRadio' value='"+warehouseObj.groupCode+"' ></td>";
								tbodyStr += "<td>"+warehouseObj.groupCode+"</td>";
								tbodyStr += "<td>"+warehouseObj.groupName+"</td>";
								tbodyStr += "</tr>";
							}
							tbody.html(tbodyStr);
					   }else{
							jAlert("系统错误","温馨提示");
					   }
					   
					},
					error : function() {
						jAlert("网络繁忙，请稍后重试...","温馨提示");
						btn.attr("disabled",false);
					}
				 }); 
		}
		//确认登记
		function confirmIn(otherBillId){
			//如果otherBillId存在值就是直接登记不需要选择仓库
			if(otherBillId){
				var billId = otherBillId;
				 var btn=$("#confirmIn_btn_"+billId);
			    btn.attr("disabled",true);
			    $.ajax({
				   type : 'post',
					url : '${ctx}/instorageBill/ajaxConfirmIn',
					data : {
						billId:billId,
						selectedWarehouseCode:""
					},
					dataType : 'json',
					success : function(data) {
					   if(data==true){
					     btn.attr("class","btn btn-primary");
					     btn.attr("disabled",true);
					     btn.html("已登记");
					     $("#assignSubWarehouseDiv").trigger("click");
					   }else{
					     jAlert("网络繁忙，请稍后重试...","温馨提示");
					     btn.attr("disabled",false);
					   }
					   
					},
					error : function() {
						jAlert("网络繁忙，请稍后重试...","温馨提示");
						btn.attr("disabled",false);
					}
				 }); 
			}else {
				billId = selectBillId;
				var warehouseRadio = $("[name=warehouseRadio]:checked");
				
				if(!warehouseRadio || !(warehouseRadio.val())) {
					jAlert("请选择仓库","温馨提示");	
				}else {
					jConfirm("入库单登记到 <font color='red'>["+warehouseRadio.parent().next().next().text()+"]</font> 仓库 ,请确定操作!","温馨提醒",function(result){
				     	if(result){
							    var btn=$("#confirmIn_btn_"+billId);
							    btn.attr("disabled",true);
							    $.ajax({
								   type : 'post',
									url : '${ctx}/instorageBill/ajaxConfirmIn',
									data : {
										billId:billId,
										selectedWarehouseCode:warehouseRadio.val()
									},
									dataType : 'json',
									success : function(data) {
									   if(data==true){
									     btn.attr("class","btn btn-primary");
									     btn.attr("disabled",true);
									     btn.html("已登记");
									     $("#assignSubWarehouseDiv").trigger("click");
									   }else{
									     jAlert("网络繁忙，请稍后重试...","温馨提示");
									     btn.attr("disabled",false);
									   }
									   
									},
									error : function() {
										jAlert("网络繁忙，请稍后重试...","温馨提示");
										btn.attr("disabled",false);
									}
								 }); 
						
				     	}
				     });
				}
			}
		}
		
		function billTypeChange(){
		  var billType=$("#billType").val();
		  
		  if("cancelOrder"==billType){
		     $("#aboutCode").attr("placeholder","录入能容订单号...");
		  }
		  else if("returnOrder"==billType){
		     $("#aboutCode").attr("placeholder","录入能容订单号...");
		  }else{
		     $("#aboutCode").attr("placeholder","录入相关单号...");
		  }
		  
		}
		
	function outReturnExcel(){
		var customerCode = $("#_customerCode").val();
		var warehouseCode = $("#_warehouseCode").val();
		if(warehouseCode == ""){
			alert("请选择仓库！");
			return;
		}
		if(customerCode == "TST"){
			$("#queryForm").attr("action","${ctx}/instorageBill/outReturnExcel");
			$("#queryForm").submit();
		}else{
			alert("只有美的的才能导出");
			return;
		}
		
	}
	//重发奇门接口成功
	function sendqm(billId){
		 var btn=$("#sendqm_btn_"+billId);
		$.ajax({
			   type : 'post',
				url : '${ctx}/instorageBill/repeatSendQM',
				data : {
					billId:billId,
				},
				dataType : 'json',
				success : function(data) {
				   if(data==true){
					   jAlert("重发成功","温馨提示");
					   btn.attr("class","btn btn-primary");
					   btn.attr("disabled",true);
				   }else{
					   jAlert("重发失败","温馨提示");
				   }
				},
				error : function() {
					jAlert("网络繁忙，请稍后重试...","温馨提示");
				}
		});
	}
</script>
</head>

<body>
<section class="content">
 <c:if test="${not empty message}">
		<div id="message" class="alert alert-success"><button data-dismiss="alert" class="close">×</button>${message}</div>
	</c:if>
	<div class="row">
		<div class="col-md-12">

			<!-- Primary box -->
			<div class="box box-solid box-primary">
				<div class="box-header">
					<i class="fa fa-search"></i>
					<h3 class="box-title">搜索栏</h3>
					<div class="box-tools pull-right">
						<button class="btn btn-primary btn-sm" data-widget="collapse">
							<i class="fa fa-minus"></i>
						</button>
					</div>
				</div>
				<div class="box-body">
	<form class="form-search" id="queryForm" >
	    <input id="_orderbystatus" name="_orderbystatus"  value="status" type="hidden"/>
		<div class="form-group row">
			<div class="col-sm-3">
			<div class="input-group col-sm-12">
			    <label class="input-group-text">商家:</label>
				 <select  name="_customerCode"  id="_customerCode" value="${param._customerCode}"  class="form-control" onchange="ajaxAreaGroup(this,'_warehouseCode');">
					<option value=""></option>
					<c:forEach items="${customerList}" var="customer">
						<option value="${customer.customerCode}"
						<c:if test="${customerCode eq customer.customerCode}">selected=selected</c:if>
						>${customer.customerName}</option>
					</c:forEach>
				</select>
			</div>
			</div>
				
			<div class="col-sm-3">
			<div class="input-group col-sm-12">	
				<label class="input-group-text">入库仓库:</label>
				   <select  name="_warehouseCode"  id="_warehouseCode" value="${param._warehouseCode}"  class="form-control" >
				     <option value=""></option>  
				     <c:forEach items="${warehouseList}" var="warehouse">
				       <option value="${warehouse.groupCode}" 
				       <c:if test="${warehouseCode eq warehouse.groupCode }">selected=selected</c:if>
				       >${warehouse.groupName}</option>
				     </c:forEach>
				</select>
			</div>
			</div>
			<div class="col-sm-3">
			<div class="input-group col-sm-12">	
				<label class="input-group-text">入库单状态：</label> 
				<!-- 
				0:待登记 (调拨货品已出库，尚未入库) 1.入库登记  2.领取点收任务   3.点收完成   4.领取上架任务   5.上架完成 6.取消
				 -->
				<select  name="_status"  id="_status" value="${param._status}"  class="form-control">
					<option value="" <c:if test="${status eq ''}">selected=selected</c:if> ></option>
					<option value="0" <c:if test="${status eq '0'}">selected=selected</c:if> >待登记</option>
				    <option value="1" <c:if test="${status eq '1'}">selected=selected</c:if> >已登记</option>
				    <option value="2" <c:if test="${status eq '2'}">selected=selected</c:if> >领取点收任务 </option>
				    <option value="3" <c:if test="${status eq '3'}">selected=selected</c:if> >点收完成</option>
				    <option value="4" <c:if test="${status eq '4'}">selected=selected</c:if> >领取上架任务</option>
				    <option value="5" <c:if test="${status eq '5'}">selected=selected</c:if> >上架完成</option>
				    <option value="6" <c:if test="${status eq '6'}">selected=selected</c:if> >取消</option>
					<!-- 
				    <option value="0" <c:if test="${status eq '0'}">selected=selected</c:if> >待登记</option>
				    <option value="1" <c:if test="${status eq '1'}">selected=selected</c:if> >已登记</option>
				    <option value="2" <c:if test="${status eq '2'}">selected=selected</c:if> >已点收</option>
				    <option value="3" <c:if test="${status eq '3'}">selected=selected</c:if> >审核通过</option>
				    <option value="4" <c:if test="${status eq '4'}">selected=selected</c:if> >审核驳回</option>
				    <option value="5" <c:if test="${status eq '5'}">selected=selected</c:if> >任务执行中</option>
				    <option value="6" <c:if test="${status eq '6'}">selected=selected</c:if> >完成所有任务</option>
				     -->
				</select>
			</div>
			</div>
			
			<div class="col-sm-3">
			<div class="input-group col-sm-12">	
				<label class="input-group-text">入库单号：</label> 
				<input type="text" name="_billCode" id="_billCode"  class="form-control" value="${param._billCode}"/>
		    </div>
		    </div>
		</div>
		<div class="form-group row">
		
			<div class="col-sm-3">
				<div class="input-group col-sm-12">	
					<label class="input-group-text">入库日期：</label>
					<div class="input-group-addon">
						<i class="fa fa-calendar"></i>
					</div>
				 	<input type="text" name="_fromDate" id="_fromDate"  class="form-control value="${param._fromDate}"/> 
				 </div>
			 </div>
			 
			<div class="col-sm-3">
				<div class="input-group col-sm-12">	
				 	<label class="input-group-text">至</label>
				 	<div class="input-group-addon">
						<i class="fa fa-calendar"></i>
					</div>
				 	<input type="text" name="_toDate" id="_toDate" class="form-control" value="${param._toDate}" /> 
				 </div>
			 </div>
			 
			 <div class="col-sm-3">
				<div class="input-group col-sm-12">	
				 	<label class="input-group-text">客户单号：</label> 
					<input type="text" name="_customerOrderNo" id="_customerOrderNo"  class="form-control" value=""/>
				 </div>
			 </div>
			 
			 <div class="col-sm-3">
				<div class="input-group col-sm-12">	
				    <button type="button" class="btn btn-info" onclick="load()">搜索</button>
				    <a   href="#detail" role="button" data-toggle="modal" id="${timeliness.orderNo}" class="btn btn-primary" onclick="add();" >登记入库</a>
				    <a role="button"  onclick="outReturnExcel()" class="btn btn-info" >导出退货入库Excel</a>
			    </div>
			</div>
			
		</div>
		    
	   </form>
	</div>
	</div>
	</div>
	</div>
	
	
	<div class="form-group row">
		<div class="col-md-12">
			<div class="box box-solid box-primary">
				<div class="box-header">
					<i class="fa fa-list"></i>
					<h3 class="box-title">查询结果</h3>
					<div class="box-tools pull-right">
						<button class="btn btn-primary btn-sm" data-widget="collapse" type="button">
							<i class="fa fa-minus"></i>
						</button>
					</div>
				</div>
				<div class="box-body">

	
	<table id="contentTable" class="table table-striped table-bordered table-condensed">
		<thead><tr>
		    <th>序号</th>
		    <th style="width: 60px;">商家</th>
		    <th style="width: 60px;">入库类型</th>
		    <th style="width: 60px;">商品类型</th>
		    <th style="width: 60px;">入库仓</th>
		    <th style="width: 60px;">出库仓</th>
		    <th style="width: 60px;">入库单号</th>
		    <th style="width: 60px;">相关单号</th>
		    <th style="width: 60px;">客户单号</th>
		    <th style="width: 60px;">原始单号</th>
		    <th style="width: 60px;">快递单号</th>
			<th style="width: 60px;">箱子数</th>
			<th style="width: 60px;">SKU数</th>
			<th style="width: 60px;">商品数</th>
			<th style="width: 130px;">登记时间</th>
			<th style="width: 60px;">状态</th>
			<th style="width: 60px;">是否异常</th>
			<th style="width: 60px;">创建人</th>
			<th style="width: 180px;"><div onclick="load('status')">管理</div></th>
		</tr></thead>
		<tbody>
		</tbody>
	</table>
	</div>
	</div></div>
	</div>
	
	<!-- 添加/修改入库单 -------------------------------------------------------------------------------------------------->
	<div class="modal fade"  id="detail" >
	<form id="inputForm"  method="post" class="form-horizontal">
		<div class="modal-dialog" style="height: 300px; width: 900px">
			<div class="modal-content"  >
	
		<!-- 头 -->
		<div class="modal-header">
		<span style="font-size: large; font-weight: bold;" id="windowTitle"></span>
		</div>
		<!-- 体 -->
		<div class="modal-body">
						<fieldset>
						      <input type="hidden" id="id" name="id"/>
						      
							  <!-- 行1 -->
						      <div class="form-group row">
								<div class="col-sm-4">
									<div class="input-group col-sm-12">
												<label  class="input-group-text">商家名称:</label>
													 <select  name="customerCode"  id="customerCode"  class="form-control required" onchange="ajaxAreaGroup(this,'inwarehouseCode');">
														<option value=""></option>
														<c:forEach items="${customerList}" var="customer">
														<option value="${customer.customerCode}"  openqm="${customer.openQm}"
														<c:if test="${customerCode eq customer.customerCode}">selected=selected</c:if>
														>${customer.customerName}</option>
														</c:forEach>
													</select>
							          </div>
							          </div>
							          
				       				<div class="col-sm-4">
									<div class="input-group col-sm-12">
							        
											
												<label  class="input-group-text">入库仓库:</label>
													<select id="inwarehouseCode" name="inwarehouseCode" class="form-control required"   >
														<option value=""></option>
														<c:forEach items="${warehouseList}" var="wm">
															<option value="${wm.groupCode}">${wm.groupName}</option>
														</c:forEach>
													</select>
							          </div>
							          </div>
							          
									<div class="col-sm-4">
									<div class="input-group col-sm-12">						               
							               <label  class="input-group-text" >是否破损:</label>
														<select id="errorFlag" name="errorFlag" class="form-control required" >
															<option value="noterror">完好件</option>
															<option value="error">破损件</option>
														</select>
								         </div>
							          </div>
						       </div>
						       
							       
							   <!-- 行2 -->
							   <div class="form-group row">
								   <div class="col-sm-4">
									<div class="input-group col-sm-12">
											<label  class="input-group-text" >入库类型:</label>
												<select id="billType" name="billType" class="form-control required" onchange="billTypeChange();"  >
													<option value=""></option>
													<option value="customer" selected="selected">采购入库</option>
<!-- 															<option value="allot">调拨入库</option> -->
<!-- 															<option value="cancelOrder">取消单入库</option> -->
<!-- 															<option value="returnOrder">退回件入库</option> -->
												</select>
										   </div>
							          </div>
							          
								    <div class="col-sm-4">
									<div class="input-group col-sm-12">
											<label  class="input-group-text" >相关单号:</label>
											    <input type="text" id="aboutCode" class="form-control" name="aboutCode" placeholder='请录入相关单号...'/>
									</div>
							        </div>
						       </div>           
							       
						      <!-- 行4 -->
						      <div class="form-group row">
						      	<div class="col-sm-12">
								<div class="input-group col-sm-12">
										<label  class="input-group-text" >备注信息:</label>
											<textarea rows="4" id="remarks" class="form-control" name="remarks"  maxlength="100"></textarea>
						    	 </div> 
						    	 </div>
						     </div>
						     
							</fieldset>	      
		      
		</div>
		<!-- 尾 -->
		<div class="modal-footer bg-gray">
			<input id="submit_btn" class="btn btn-primary"  type="button" value="提交" onclick="mySubmit();"/>&nbsp;	
			<input id="cancel_btn" class="btn btn-primary" type="button" data-dismiss="modal" value="返回" />
			<input type="reset" style="display:none;" /> 
		</div>
		</div>
		</div>
        </form> 
     </div>
     <!------------------------------------------------------------------------------------------------------------->
     
     
     <div class="modal fade"
			tabindex="-1" role="dialog" aria-labelledby="myModalLabel"
			aria-hidden="true" style="width:1400;" id="assignSubWarehouseDiv">
			<div class="modal-dialog" >
			<div class="modal-content" >
			<div class="modal-header">
				<h3 id="myModalLabel">
					分配仓库
				</h3>
			</div>
			<div class="modal-body" style="width: 1300;height:300px; overflow: auto;">
				<table class="table table-striped table-bordered table-condensed"
					id="subWarehouseList">
					<thead>
						<tr>
							<th></th>
							<th>仓库编码</th>
							<th>仓库名称</th>
						</tr>
					</thead>
					<tbody id="selectAssignWarehouseBody">
						
					</tbody>
				</table>
			</div>
			<div class="modal-footer">
				<a href="#" onclick="confirmIn()" role="button"  class="btn btn-primary" data-toggle="modal">
					确认登记
				</a>
				<button class="btn" data-dismiss="modal" aria-hidden="true">
					关闭
				</button>
			</div>
		</div>
		</div>
	</div>
	
	
</section>	
</body>
</html>
